package com.youkeda.meetingroom.controller;

import com.youkeda.meetingroom.model.PasswordParam;
import com.youkeda.meetingroom.model.Result;
import com.youkeda.meetingroom.service.PasswordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
public class PasswordController {

    @Autowired
    private PasswordService passwordService;

    /**
     * 生成一条密码
     * @param passwordParam
     * @return
     */
    @RequestMapping(value = "/password/generagePwd", method = RequestMethod.POST)
    public Result generagePwd(@RequestBody PasswordParam passwordParam){
        Result result = new Result();
        if(passwordParam != null) {
            result = passwordService.generagePwd(passwordParam.getUserId(), passwordParam.getMeetingRoomId());
        }else{
            result.setSuccess(false);
        }
        return result;

    }
    /**
     * 用户手动获取密码界面
     * @param passwordParam
     * @return
     */
    @RequestMapping(value = "/password/getPwd", method = RequestMethod.POST)
    public Result getPwd(@RequestBody PasswordParam passwordParam){
        Result result = new Result();
        if(passwordParam != null) {
            result = passwordService.getPwd(passwordParam.getBookRecordId());
        }else{
            result.setSuccess(false);
        }
        return result;

    }

}
